package _06反射获取public的构造方法Constructor;

import com.asin.domain.Person;

import java.lang.reflect.Constructor;

public class DemoGetConstructot {
    public static void main(String[] args) throws NoSuchMethodException {
        //获取Class对象
        Class<Person> personClass = Person.class;

        //获取public权限构造方法数组(包含父类)
        Constructor<?>[] constructors = personClass.getConstructors();
        for (Constructor<?> constructor : constructors) {
            System.out.println(constructor);
        }

        //获取单个构造方法--有参构造(public)
        Constructor<Person> c = personClass.getConstructor(String.class, int.class);
        System.out.println(c);

        //获取单个构造方法--无参构造(public)
        Constructor<Person> c1 = personClass.getConstructor();
        System.out.println(c1);



    }
}
